//
//  LoadingViewController.m
//  CargocnRun
//
//  Created by mac on 2017/3/24.
//  Copyright © 2017年 mac. All rights reserved.
//

#import "LoadingViewController.h"
#import "Request_LoginInfo_Model.h"
#import "AFNetworking.h"
#import "ModelToJson.h"
#import "NSObject+AutoDescription.h"
#import "NetDataPath.h"
@interface LoadingViewController ()

@end

@implementation LoadingViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    [self createView];
}
-(void)createView
{
    CGSize viewSize = [UIScreen mainScreen].bounds.size;
    NSString *viewOrientation = @"Portrait";    //横屏请设置成 @"Landscape"
    NSString *launchImage = nil;
    
    NSArray* imagesDict = [[[NSBundle mainBundle] infoDictionary] valueForKey:@"UILaunchImages"];
    for (NSDictionary* dict in imagesDict)
    {
        CGSize imageSize = CGSizeFromString(dict[@"UILaunchImageSize"]);
        
        if (CGSizeEqualToSize(imageSize, viewSize) && [viewOrientation isEqualToString:dict[@"UILaunchImageOrientation"]])
        {
            launchImage = dict[@"UILaunchImageName"];
        }
    }
    
    
    UIImage* img = nil;
    img = [[LocalDataManager sharedLocalDataManager] getImageWithName:@"loadimg" directoryName:@"pic"];
    if(img == nil)
    {
        img = [UIImage imageNamed:launchImage];
    }
    UIImageView *imageView=[[UIImageView alloc] initWithImage:img];
    imageView.frame= [UIScreen mainScreen].bounds;
    imageView.contentMode = UIViewContentModeScaleToFill;
    
    [self.view addSubview:imageView];
    
    
    [self topush];
}
-(void)topush
{
    NSUserDefaults *TimeOfBootCount = [NSUserDefaults standardUserDefaults];
    if (![TimeOfBootCount valueForKey:@"time"])
    {
        [TimeOfBootCount setValue:@"sd" forKey:@"time"];
        [[AppDelegate sharedInstance] gotoIntroController];
        NSLog(@"第一次启动");
    }else{
        NSLog(@"不是第一次启动");
        [[AppDelegate sharedInstance] gotoRootController];
//        [[AppDelegate sharedInstance] userTokenToLogin];
    }
}
- (void)send_getLoginInfo
{
//    Request_LoginInfo_Model* requestModel = [[Request_LoginInfo_Model alloc] init];
//    requestModel.userPhone = @"18616726563";
//    requestModel.verifyCode = @"";
//    requestModel.localRequestFailureType = 1;
//    requestModel.localUrlType = 0;
//    requestModel.transCode = @"DriverLogin";
//    requestModel.localHasUpdateSession = NO;
//    requestModel.methodName = @"carfreerAppLogin.do";
//    requestModel.httpUrl = @"http://test.cargocn.cn/cargocn-cloud-server/";
////    requestModel.httpUrl = @"http://test.cargocn.cn/cargocn-cloud-server/carfreerDriver/";
//    ILog(@"%@",requestModel);
//    [[NetDataPath sharedInstance] requestDataWith:self WithModel:requestModel complition:^(id result, id requestError) {
//        ILog(@"这里是请求的数据%@---%@",result,requestError);
//    }];
  
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
